#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <sys/time.h>

#define getcurrenttime(arg1, arg2) syscall( 299, arg1, arg2 )


int main() {

	struct timespec currTime;
   	
	printf("\nCalling getcurrenttime with the print flag on\n");
        int ret = getcurrenttime( 1, &currTime );

        printf("\ngetcurrenttime returned: %d\n", ret);
	printf("\nContents of the timespec: \n");
	printf("Secs: %ld ; nsecs: %ld\n", currTime.tv_sec, currTime.tv_nsec);


	struct timeval tv;
	printf("\nCalling gettimeofday for comparison.\n");
	gettimeofday( &tv, NULL );
	printf("\nThe current time is %ld seconds.\n", tv.tv_sec);

        sleep(1);

	printf("\n\nCalling getcurrenttime with the print flag off\n");
        ret = getcurrenttime( 0, &currTime );

        printf("\ngetcurrenttime returned: %d\n", ret);
	printf("\nContents of the timespec: \n");
	printf("Secs: %ld ; nsecs: %ld\n", currTime.tv_sec, currTime.tv_nsec);

	printf("\nCalling gettimeofday for comparison.\n");
	gettimeofday( &tv, NULL );
	printf("\nThe current time is %ld seconds.\n", tv.tv_sec);
	

	printf("\n\nExiting.\n\n");

	return 0;


}
